package com.red.star.wechat.work.site.admin.mapper;


import com.red.star.wechat.data.core.base.MyMapper;
import com.red.star.wechat.work.entity.Admin;
import com.red.star.wechat.work.entity.Role;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Set;

/**
 * Created by xulonglong on 2017/6/15.
 */
public interface AdminMapper extends MyMapper<Admin> {

    Admin findAdminByUsername(String username);

    List<Admin> findAll();

    Admin findAdminByEmployeeId(String employeeId);

    void addAdminAndRole(@Param("id") Integer id, @Param("roleId") Integer roleId);

    void updateAdmin(Admin admin);

    void deleteAdminAndRole(Integer id);

    void deleteAdminById(Integer id);

    List<Admin> queryAllAdminByEnumValue();

    @Select(value = "select * from t_admin where mall_code=#{mallCode} and username=#{userName}")
    Admin findAdminByMallCode(@Param("mallCode") String mallCode,@Param("userName") String userName);

    @Insert(value = "insert into t_admin_role (admin_id,role_id) values(#{adminId},#{roleId})")
    void insertAdminRole(@Param("adminId") Integer adminId, @Param("roleId") Integer roleId);

    Admin findAdminByUsernameAValue(@Param("username") String username, @Param("enumValue") String enumValue);

    Set<Role> findRoleSetByAdminId(@Param("adminId") Integer adminId);

    Set<Role> findRoleSetByEnumValue(List<String> enumValueList);

    @Select(value = "select id,`name` from t_admin")
    List<Admin> findAllName();

}
